const isDev = process.env.NODE_ENV === "development";
// const baseURL = isDev ? "http://localhost:1000" : "http://youyi.asia:1000";
const baseURL = "http://localhost:1000";
module.exports = {
  mode: 'universal',
  /*
  ** Headers of the page
  */
  head: {
    title: process.env.npm_package_name || '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
    'element-ui/lib/theme-chalk/index.css',
    'assets/css/reset.css',
    'assets/font/iconfont.css',
    'assets/css/theme/index.css',
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: ["@/plugins/element-ui", 
  //"@/plugins/axios"
],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: [
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
  ],
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
    baseURL: baseURL,
    browserBaseURL: baseURL,
    credentials: true,
    debug: false,
    // 非常重要，后端请求的时候会带上cookie
    proxyHeaders: true,
    // 忽略掉host，否则错误的host将引起nginx代理转发的失败
    proxyHeadersIgnore: ["host"],
    redirectError: {
      401: "/login"
    }
  },

  proxy: {
    "/api/": {
      target: "http://localhost:8080/",
      // target: "http://localhost:8080/",
      pathRewrite: {
        "^/api": "/centrifugeApi"
      }
    },
    "/mqttserver/": {
      // target: isDev?"http://localhost:2000/":'http://youyi.asia:2000/',
      target: "http://localhost:2000/",
      pathRewrite: {
        // "^/api": "/"
      }
    }
  },
  /*
  ** Build configuration
  */
  build: {
    transpile: [/^element-ui/],
    extractCSS: true,
    /*
    ** You can extend webpack config here
    */
    extend (config, ctx) {
    }
  }
}
